package com.jastar.android.game.richman.logic.Event;

import com.jastar.android.game.richman.GameActivity;
import com.jastar.android.game.richman.logic.bean.Cell;
import com.jastar.android.game.richman.logic.bean.Player;
import com.jastar.android.game.richman.logic.enums.CellType;
import com.jastar.android.util.Alert;

public class BaseEvent extends Event {

    private final BaseEventDealHandler handler;

    public BaseEvent(String message, int weight, BaseEventDealHandler handler) {
        super(message, weight);
        this.handler = handler;
    }

    public void hand(GameActivity activity, Cell cell, Player p, CellType.Callback callback) {
        Alert.info(activity, p.getIcon(), this.message, "确定", (d, w) -> {
            handler.deal(activity, cell, p);
            callback.callback();
        });
    }

    public interface BaseEventDealHandler {
        void deal(GameActivity activity, Cell cell, Player p);
    }

}
